home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!news
- From: miker3@ix.netcom.com (Mike Rubenstein)
- Newsgroups: comp.lang.c++
- Subject: Re: int (*p)[4]; (Watcom problem)
- Date: Fri, 12 Apr 1996 18:17:45 GMT
- Organization: Netcom
- Message-ID: <316e9d18.157768629@nntp.ix.netcom.com>
- References: <4kcd03$37j@morgoth.sfu.ca>
- NNTP-Posting-Host: ix-dc11-06.ix.netcom.com
- X-NETCOM-Date: Fri Apr 12 1:15:51 PM CDT 1996
- X-Newsreader: Forte Agent .99d/32.182
-
- mpohores@news.sfu.ca (Michael John Pohoreski) wrote:
-
- > I came across (ARM, page 97) the following way to define
- > a pointer to an array:
- > int (*p)[];
- >
- > (Yes, I allready know I can just do: int *p)
- > So I tried it in a small C++ test program: p2a.cpp
- >
- > #include <stdio.h>
- >
- > void main( void )
- > {
- > int a[4] = { -13, 11, -7, 5 };
- > int (*x)[4]; // pointer to array
- >
- > for (int i = 0; i < 4; i++ )
- > {
- > (int *)x = &a[i];
- > printf( "%d\n", (*x)[0] );
- > }
- > }
- >
- > Now here's my problem:
- > Under Watcom 10.5, the above doesn't compile with wcl386
- > but it compiles under DJGPP 2.0, and Borland C++ 3.1 Anyone know why?
- >
- > Is this a bug?
-
- Watcom is correct. I don't know about DJGPP, but in Borland C++ this
- is an extension to the language. Version 5.0 correctly rejects this
- if the -A switch is used.
-
- The problem is that (int *)x is not an lvalue and may not appear as
- the left operand of assignment.
-
- Why not use the correct syntax?
-
- x = &a;
-
-
- Michael M Rubenstein
-